﻿using B.S.Database.Domain.Entity;
using B.S.Database.ErrorCode;
using B.S.Database.Interface.Interface;
using B.S.Database.Read.Api.Application.Commands.Image;
using MediatR;

namespace B.S.Database.Read.Api.Application.CommandHandler.Image
{
    public class PictureShowCommandHandler : IRequestHandler<PictureShowCommands, Apiresult<List<Picture_Information>>>
    {
        private readonly IBaseResotity<Picture_Information> pictureRepo;

        public PictureShowCommandHandler(IBaseResotity<Picture_Information> PictureRepo)
        {
            pictureRepo = PictureRepo;
        }
        public Task<Apiresult<List<Picture_Information>>> Handle(PictureShowCommands request, CancellationToken cancellationToken)
        {
            Apiresult<List<Picture_Information>> res = new Apiresult<List<Picture_Information>>();
            res.Code = ApiEnums.成功;
            res.Message = ApiEnums.成功.ToString();
            var list = pictureRepo.GetAll().Where(c=>c.TraceabilityId==request.TraceabilityId);
            res.Data = list.ToList();
            return Task.FromResult(res);
        }
    }
}
